<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>find函数的使用</title>
</head>

<body>
    <script>
        const phone = [
            {
                name: '小米',
                price: 2999
            },
            {
                name: '华为',
                price: 4999
            }
        ]
        
        // find返回数组元素 没有匹配时返回undefined
        const xiaomi = phone.find(element => element.name === '小米')
        console.log(xiaomi);
    </script>
</body>

</html>